<?php

use think\migration\Migrator;
use think\migration\db\Column;

class UserRefund extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table  =  $this->table('user_refund',array('comment'=>'用户提现表'));
        $table->addColumn('user_id', 'integer',array('limit'  => 11,'default'=>0,'comment'=>'用户id',"null"=>true))
        ->addColumn('payment_no', 'string',array('limit'  => 50,'default'=>'','comment'=>'付款单号',"null"=>true))
        ->addColumn('merchant_number', 'string',array('limit'  => 50,'default'=>'','comment'=>'商户单号',"null"=>true))
        ->addColumn('bank_card', 'string',array('limit'  => 50,'default'=>'','comment'=>'银行卡号',"null"=>true))
        ->addColumn('bank_name', 'string',array('limit'  => 120,'default'=>'','comment'=>'所属银行',"null"=>true))
        ->addColumn('bank_short', 'string',array('limit'  => 120,'default'=>'','comment'=>'所属银行简称',"null"=>true))
        ->addColumn('user_name', 'string',array('limit'  => 120,'default'=>'','comment'=>'用户姓名',"null"=>true))
        ->addColumn('phone', 'string',array('limit'  => 120,'default'=>'','comment'=>'用户电话',"null"=>true))
        ->addColumn('sub_branch', 'string',array('limit'  => 120,'default'=>'','comment'=>'银行卡所在支行',"null"=>true))
        ->addColumn('real_fee', 'float', array('limit' => "10,2",'default'=>0,"comment"=>"实际到款金额（元）","null"=>true))
        ->addColumn('service_fee', 'float', array('limit' => "10,2",'default'=>0,"comment"=>"手续费金额（元）","null"=>true))
        ->addColumn('refund_fee', 'float', array('limit' => "10,2",'default'=>0,"comment"=>"实际扣款金额（元）","null"=>true))
        ->addColumn('status', 'enum',array('values' => "0,1,2,3,4","comment"=>"使用状态:0=审核中,1=审核成功打款中,2=打款成功,3=打款失败,4=审核失败","null"=>true))
        ->addColumn('type', 'enum',array('values' => "0,1,2","comment"=>"短信类型:0=银行卡提现,1=微信提现,2=支付宝提现","null"=>true))
        ->addColumn('remake', 'string',array('limit'  => 500,'default'=>'','comment'=>'备注',"null"=>true))
        ->addColumn('payment_time', 'integer',array('limit' => 10,"comment"=>"打款时间","null"=>true))
        ->addColumn('createtime', 'integer', array('limit' => 10,"comment"=>"新增时间","null"=>true))
        ->addColumn('updatetime', 'integer', array('limit' => 10,"comment"=>"更新时间","null"=>true))
        ->addIndex(array('user_id'))
        ->addIndex(array('payment_no'))
        ->addIndex(array('bank_card'))
        ->create();
    }
}
